<?php
namespace PackageSpy;
use Nette;
class PackageStateModel extends Nette\Object
{
	protected $connection;

	public function __construct(Nette\Database\Connection $db)
	{
		$this->connection = $db;
	}

	protected function getTable()
	{
		return $this->connection->table('packagestate');
	}
	
	//ověří zda existují stavy předané parametrem a neexistující uloží
	public function savePackageState($refpackage, $packageStates)
	{
		foreach ($packageStates as $packageState){
			$row = $this->getTable()->insert(array('description' => $packageState, 'refpackage' => $refpackage));
		}
	}	

}